# -*- coding: utf-8 -*-
import logging

from redis import StrictRedis


class Config():
    DEBUG= True

    SECRET_KEY = "+UVHSdLAs1Vl7tNwJGGN5cSDEoOG8psOssJbiNe/njx+n4+oe/Z2r1LhlUAfVKIc"
    #为数据库添加配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:1102@127.0.0.1:3306/information"
    SQLALCHEMY_TRACK_MODIFICATIONS =False
    # 在请求结束时候，如果指定此配置为 True ，那么 SQLAlchemy 会自动执行一次 db.session.commit()操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    #redis的配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    #session保存配置
    SESSION_TYPE = "redis"
    #开启session签名
    SESSION_USE_SIGNER = True
    #指定session保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    #设置需要过期
    SESSION_PERMANENT = False
    #设置过期时间
    PERMANENT_SESSION_LIFETIME = 86400*2
    #设置日志的等级
    LOG_LEVEL = logging.DEBUG


class Testingconfig(Config):
    DEBUG = False
    TESTING = True

class Developmentconfig(Config):
    DEBUG = True

class Productionconfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING


config = {
    "development": Developmentconfig,
    "testing": Testingconfig,
    "product":Productionconfig
}